import javax.swing.JTextArea;
import java.io.*;

public class ConversationManager implements Serializable {
	
	private Player player;
	private Character NPC;
	private JTextArea feedback;
	private JTextArea outputarea;
	private enum Choice { STRENGTH, AGILITY, ENDURANCE, INTELLIGENCE, WILLPOWER, WAKE, STOP, END, FINISH, INVALID }
	
	public ConversationManager(JTextArea y) {
		feedback = y;
	}

	
	public void parseCmd(String a, JTextArea outputarea, Player player) {
		Choice choice = Choice.INVALID;
		
		for (Choice b : Choice.values()) {
			if (a.equalsIgnoreCase(b.toString())) {
				choice = b;
			}
		}
		
		switch (choice) {
		case STRENGTH:
			if (player.getSkillPoints() >= 5) {
				player.modifyStrength(1);
				player.modifySkillPoints(-5);
				outputarea.append("Your strength increases by 1.\n");
			} else {
				outputarea.append("You don't have enough skill points remaining to do that!\n");
			}
			break;
		case AGILITY:
			if (player.getSkillPoints() >= 5) {
				player.modifyAgility(1);
				player.modifySkillPoints(-5);
				outputarea.append("Your agility increases by 1.\n");
			} else {
				outputarea.append("You don't have enough skill points remaining to do that!\n");
			}
			break;
		case ENDURANCE:
			if (player.getSkillPoints() >= 5) {
				player.modifyEndurance(1);
				player.modifySkillPoints(-5);
				player.updateMaxHP();
				outputarea.append("Your endurance increases by 1.\n");
			} else {
				outputarea.append("You don't have enough skill points remaining to do that!\n");
			}
			break;
		case INTELLIGENCE:
			if (player.getSkillPoints() >= 5) {
				player.modifyIntelligence(1);
				player.modifySkillPoints(-5);
				outputarea.append("Your intelligence increases by 1.\n");
			} else {
				outputarea.append("You don't have enough skill points remaining to do that!\n");
			}
			break;
		case WILLPOWER:
			if (player.getSkillPoints() >= 5) {
				player.modifyWillpower(1);
				player.modifySkillPoints(-5);
				outputarea.append("Your Willpower increases by 1.\n");
			} else {
				outputarea.append("You don't have enough skill points remaining to do that!\n");
			}
			break;
		case WAKE:
		case STOP:
		case END:
		case FINISH:
			player.Sleep(false);
			feedback.append("You awake from your sleep.");
			break;
		default:
			feedback.append("You are currently sleeping, please select an attribute to increase, or use 'wake' to wake up.");
		break;
		}
	}

}
